﻿using NfsBLL;
using NfsModel;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Web;
using System.Web.Mvc;

namespace MobileWeb.Controllers
{
    [BaseController(IsCheck = false)]
    public class QueryController : Controller
    {
        //
        // GET: /Query/
        public ActionResult Index()
        {
            //ToImage();
            return View();
        }
        private void ToImage()
        {
            string base64 = "";
            base64 = base64.Replace("data:image/png;base64,", "");
            base64 = base64.Replace("data:image/jpeg;base64,", "");
            base64 = base64.Replace("data:image/x-icon;base64,", "");
            base64 = base64.Replace(",", "");
            byte[] bytes = Convert.FromBase64String(base64);
            MemoryStream memStream = new MemoryStream(bytes);
            Bitmap img = new Bitmap(memStream);
            img.Save("F:\\taskimg\\a.jpg");
         
            
        }
        /// <summary>
        /// 获取授权证书
        /// </summary>
        /// <returns></returns>
        public JsonResult GetAuImg()
        {

            try
            {
                AgencyBLL bll = new AgencyBLL();
                string codes = Request["codes"] != "" ? Request["codes"] : "";
              agency  model=bll.GetModel_ByCodes(codes);
              if (model != null)
              {
                  return Json(new { MessageCode = "0",model=model }, JsonRequestBehavior.AllowGet);

              }
              else {
                  return Json(new { MessageCode = "100" }, JsonRequestBehavior.AllowGet);

              }

                
            }
            catch (Exception)
            {

                return Json(new { MessageCode = "200" }, JsonRequestBehavior.AllowGet);
            }
        }
	}
}